//
//  AppDelegate.m
//  TestDrawer_--001
//
//  Created by 刘杨 on 15/9/8.
//  Copyright (c) 2015年 刘杨. All rights reserved.
//

#import "AppDelegate.h"
#import "LYRightViewController.h"
#import "LYLeftViewController.h"
#import "LYMainViewController.h"
#import "LYDrawer.h"

@interface AppDelegate ()
@property (nonatomic, strong) LYDrawer *drawer;

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    
    LYLeftViewController *leftVC = [[LYLeftViewController alloc] init];
    LYRightViewController *rightVC = [[LYRightViewController alloc] init];
    LYMainViewController *mainVC = [[LYMainViewController alloc] init];
    UINavigationController *mainNC = [[UINavigationController alloc] initWithRootViewController:mainVC];
    mainVC.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Left" style:UIBarButtonItemStylePlain target:self action:@selector(leftBarButtonItemAction:)];
    mainVC.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBarButtonItemStylePlain target:self action:@selector(rightBarButtonItemAction:)];

    
    _drawer = [[LYDrawer alloc] initWithMainViewController:mainNC leftViewController:leftVC rightViewController:rightVC];
//    _drawer.isSwipeGesture = NO;
//    _drawer.animationDuration = 1.0;
//    _drawer.drawerWidth = 130;
    _drawer.rightBackgroudImage = [UIImage imageNamed:@"Balloon"];
    _drawer.leftBackgroudImage = [UIImage imageNamed:@"Stars"];

    
    self.window.rootViewController = _drawer;
    
    return YES;
}

- (void)leftBarButtonItemAction:(UIBarButtonItem *)sender{
    [_drawer presentLeftDrawerController];
}

- (void)rightBarButtonItemAction:(UIBarButtonItem *)sender{
    [_drawer presentRightDrawerController];
}


@end
